<!DOCTYPE html>












  


<html class="theme-next pisces use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
























<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2">

<link rel="stylesheet" href="/css/main.css?v=7.1.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.1.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/logo1.jpg?v=7.1.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/logo1.jpg?v=7.1.0">


  <link rel="mask-icon" href="/images/logo.svg?v=7.1.0" color="#222">







<script id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '7.1.0',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false,"dimmer":false},
    back2top: true,
    back2top_sidebar: false,
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="容器快速入门教程">
<meta name="keywords" content="Container">
<meta property="og:type" content="article">
<meta property="og:title" content="容器快速入门">
<meta property="og:url" content="https://luoo.oschina.io/2016/12/02/tech/容器快速入门/index.html">
<meta property="og:site_name" content="从你的全世界路过">
<meta property="og:description" content="容器快速入门教程">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-04-14T12:28:00.736Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="容器快速入门">
<meta name="twitter:description" content="容器快速入门教程">



  <link rel="alternate" href="/atom.xml" title="从你的全世界路过" type="application/atom+xml">



  
  
  <link rel="canonical" href="https://luoo.oschina.io/2016/12/02/tech/容器快速入门/">



<script id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>容器快速入门 | 从你的全世界路过</title>
  












  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">从你的全世界路过</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">心智渐开，世事渐杂</p>
      
    
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">

    
    
    
      
    

    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">

    
    
    
      
    

    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">

    
    
    
      
    

    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">

    
    
    
      
    

    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-schedule">

    
    
    
      
    

    

    <a href="/schedule/" rel="section"><i class="menu-item-icon fa fa-fw fa-calendar"></i> <br>计划</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-you">

    
    
    
      
    

    

    <a href="/you/" rel="section"><i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>知遇</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-about">

    
    
    
      
    

    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://luoo.oschina.io/2016/12/02/tech/容器快速入门/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="方林">
      <meta itemprop="description" content="愿你出走半生，归来仍是少年">
      <meta itemprop="image" content="/images/logo1.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="从你的全世界路过">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">容器快速入门

              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2016-12-02 23:29:25" itemprop="dateCreated datePublished" datetime="2016-12-02T23:29:25+08:00">2016-12-02</time>
            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/编程技术/" itemprop="url" rel="index"><span itemprop="name">编程技术</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <span class="post-meta-item-text">评论数：</span>
                <a href="/2016/12/02/tech/容器快速入门/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2016/12/02/tech/容器快速入门/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>容器快速入门教程</p>
<a id="more"></a>
<h1 id="First-Docker-Application"><a href="#First-Docker-Application" class="headerlink" title="First Docker Application"></a><strong>First Docker Application</strong></h1><ul>
<li>下载 ubuntu:14.04</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker pull ubuntu:14.04</span><br><span class="line">fa4fd76b09ce: Pull complete </span><br><span class="line">fa4fd76b09ce: Download complete</span><br><span class="line">1c8294cc5160: Download complete</span><br><span class="line">117ee323aaa9: Download complete </span><br><span class="line">2d24f826cb16: Download complete </span><br><span class="line">511136ea3c5a: Download complete </span><br><span class="line">Status: Downloaded newer image for ubuntu:14.04</span><br><span class="line"></span><br><span class="line">//run echo &apos;Hello world&apos;</span><br><span class="line">luoo@PS:~$ docker run ubuntu:14.04 bin/echo &apos;Hello world&apos;</span><br><span class="line">Hello world</span><br></pre></td></tr></table></figure>
<ul>
<li>进入容器的交互环境，-t是在容器内开启一个终端，-i进入交互环境</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker run -t -i ubuntu:14.04 /bin/bash</span><br><span class="line">root@61684a876af5:/#</span><br><span class="line">root@61684a876af5:/# pwd</span><br><span class="line">/</span><br><span class="line">root@61684a876af5:/# ls</span><br><span class="line">bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var</span><br><span class="line">root@61684a876af5:/# exit</span><br><span class="line">exit</span><br></pre></td></tr></table></figure>
<ul>
<li>-d告诉容器将任务放入后台运行</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker run -d ubuntu:14.04 /bin/sh -c &quot;while true; do echo hello world; sleep 1; done&quot;</span><br><span class="line">dc34a2103c84cc0f859f96d2a865aad85f4302c9f1056f8b4e33fbaeed5b6129</span><br></pre></td></tr></table></figure>
<ul>
<li>查看正在运行的容器</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker ps</span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">dc34a2103c84 ubuntu:14.04 &quot;/bin/sh -c \&apos;while t About a minute ago Up About a minute goofy_sinoussi</span><br></pre></td></tr></table></figure>
<ul>
<li>查看指定容器dc34a2103c84的输出</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker logs dc34a2103c84</span><br><span class="line">hello world</span><br><span class="line">hello world</span><br><span class="line">hello world</span><br><span class="line">hello world</span><br><span class="line">hello world</span><br><span class="line">hello world</span><br></pre></td></tr></table></figure>
<ul>
<li>停止容器dc34a2103c84的运行</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker stop dc34a2103c84</span><br><span class="line">dc34a2103c84</span><br></pre></td></tr></table></figure>
<ul>
<li>查看正在运行的容器</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker ps</span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br></pre></td></tr></table></figure>
<h1 id="Woking-with-Containers"><a href="#Woking-with-Containers" class="headerlink" title="Woking with Containers"></a><strong>Woking with Containers</strong></h1><ul>
<li>-P告诉Docker映射所需要的端口到本地主机</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>-l显示详细信息</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">$ docker ps -l</span><br><span class="line">CONTAINER ID  IMAGE                   COMMAND       CREATED        STATUS        PORTS                    NAMES</span><br><span class="line">bc533791f3f5  training/webapp:latest  python app.py 5 seconds ago  Up2 seconds  0.0.0.0:49155-&gt;5000/tcp  nostalgic_morse</span><br><span class="line">Docker将容器的5000端口映射到主机的49155端口，此时可以通过localhost:49155访问网站了&lt;br&gt;</span><br><span class="line">上面的-P标签相当于-p 5000，以下是自定义端口映射关系，将容器的5000端口映射到主机的5000端口&lt;br&gt;</span><br><span class="line">$ docker run -d -p 5000:5000 training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>查看容器ubuntu:14.04的5000端口映射主机的端口</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker port CONTAINERID[3~4] 50000.0.0.0:49155</span><br></pre></td></tr></table></figure>
<ul>
<li>查看容器ubuntu:14.04的输出，-f 的效果类似tail -f</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ docker logs -f CONTAINERID[3~4]</span><br><span class="line">*Running on http://0.0.0.0:5000/10.0.2.2--[23/May/201420:16:31]&quot;GET / HTTP/1.1&quot;200-10.0.2.2--[23/May/201420:16:31]&quot;GET /favicon.ico HTTP/1.1&quot;404-</span><br></pre></td></tr></table></figure>
<ul>
<li>查看容器的进程</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ docker top CONTAINERID[3~4]</span><br><span class="line">PID                 USER                COMMAND</span><br><span class="line">854                 root                python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>查看容器对应的IP</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">luoo@PS:~$ docker inspect -f &apos;&#123;&#123; .NetworkSettings.IPAddress &#125;&#125;&apos; 3589</span><br><span class="line">172.17.0.8</span><br></pre></td></tr></table></figure>
<ul>
<li>停止容器</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker stop CONTAINERID[3~4]</span><br></pre></td></tr></table></figure>
<ul>
<li>删除容器</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker rm CONTAINERID[3~4]</span><br></pre></td></tr></table></figure>
<h1 id="Working-with-Docker-Images"><a href="#Working-with-Docker-Images" class="headerlink" title="Working with Docker Images"></a><strong>Working with Docker Images</strong></h1><ul>
<li>列出本地所有容器镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">$ docker images</span><br><span class="line">REPOSITORY       TAG      IMAGE ID      CREATED      VIRTUAL SIZE</span><br><span class="line">training/webapp  latest   fc77f57ad303  3 weeks ago  280.5 MB</span><br><span class="line">ubuntu           14.045e019ab7bf6d4 weeks ago  180 MB</span><br><span class="line">ubuntu           latest   5e019ab7bf6d4 weeks ago  180 MB</span><br><span class="line">ubuntu           12.0474fe38d114014 weeks ago  209.6 MB</span><br><span class="line">ubuntu           precise  74fe38d114014 weeks ago  209.6 MB</span><br><span class="line">//一个镜像可能有多个TAG</span><br><span class="line">//通过docker run -t -i REPOSITORY:TAG /bin/bash 运行一个容器，譬如ubuntu:14.04和ubuntu:latest是运行同一个镜像</span><br></pre></td></tr></table></figure>
<ul>
<li>获取一个新的容器镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">$ docker pull centos</span><br><span class="line">Pulling repository centos</span><br><span class="line">b7de3133ff98:Pulling dependent layers</span><br><span class="line">5cc9e91966f7:Pulling fs layer</span><br><span class="line">511136ea3c5a:Download complete</span><br><span class="line">ef52fb1fe610:Download complete</span><br><span class="line">...Status:Downloaded newer image for centos</span><br><span class="line">$ docker run -t -i centos /bin/bash</span><br><span class="line">bash-4.1#</span><br></pre></td></tr></table></figure>
<ul>
<li>从Docker Hub上搜索想要的容器镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">$ sudo docker search sinatra</span><br><span class="line">NAME                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED</span><br><span class="line">training/sinatra                       Sinatra training image                          0[OK]</span><br><span class="line">marceldegraaf/sinatra                  Sinatra test app                                0</span><br><span class="line">mattwarren/docker-sinatra-demo                                                         0[OK]</span><br><span class="line">luisbebop/docker-sinatra-hello-world                                                   0[OK]</span><br><span class="line">bmorearty/handson-sinatra              handson-ruby +SinatraforHands on with D...0</span><br><span class="line">subwiz/sinatra                                                                         0</span><br><span class="line">bmorearty/sinatra                                                                      0...</span><br><span class="line">//然后可以下载相应的容器镜像</span><br></pre></td></tr></table></figure>
<ul>
<li>创建自定义的容器镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -t -i training/sinatra /bin/bash</span><br><span class="line">root@0b2616b0e5a8:/# gem install json</span><br></pre></td></tr></table></figure>
<ul>
<li>-a标识创建作者</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ docker commit -m &quot;Added json gem&quot;-a &quot;Kate Smith&quot;0b2616b0e5a8 ouruser/sinatra:v2</span><br><span class="line">4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c</span><br></pre></td></tr></table></figure>
<ul>
<li>查看创建的容器镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ docker images</span><br><span class="line">REPOSITORY          TAG     IMAGE ID       CREATED       VIRTUAL SIZE</span><br><span class="line">training/sinatra    latest  5bc342fa0b9110 hours ago  446.7 MB</span><br><span class="line">ouruser/sinatra     v2      3c59e02ddd1a10 hours ago  446.7 MB</span><br><span class="line">ouruser/sinatra     latest  5db5f847126110 hours ago  446.7 MB</span><br></pre></td></tr></table></figure>
<ul>
<li>通过Dockerfile创建镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">$ mkdir sinatra</span><br><span class="line">$ cd sinatra</span><br><span class="line">$ touch Dockerfile</span><br><span class="line"># This is a comment</span><br><span class="line">FROM ubuntu:14.04</span><br><span class="line">MAINTAINER KateSmith&lt;ksmith@example.com&gt;</span><br><span class="line">RUN apt-get update &amp;&amp; apt-get install -y ruby ruby-dev</span><br><span class="line">RUN gem install sinatra</span><br></pre></td></tr></table></figure>
<ul>
<li>利用Dockerfile和docker build命令创建一个镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">$ docker build -t ouruser/sinatra:v2 .Sending build context to Docker daemon 2.048 kB</span><br><span class="line">Sending build context to Docker daemon</span><br><span class="line">Step0: FROM ubuntu:14.04---&gt; e54ca5efa2e9</span><br><span class="line">Step1: MAINTAINER KateSmith&lt;ksmith@example.com&gt;---&gt;Using cache</span><br><span class="line"> ---&gt;851baf55332bStep2: RUN apt-get update &amp;&amp; apt-get install -y ruby ruby-dev</span><br><span class="line"> ---&gt;Runningin3a2558904e9bSelecting previously unselected package libasan0:amd64.</span><br><span class="line">...</span><br><span class="line">InstallingRDoc documentation for rack-protection-1.5.3...InstallingRDoc documentation for sinatra-1.4.5...---&gt;97feabe5d2edRemoving intermediate container 6b81cb6313e5Successfully built 97feabe5d2ed</span><br><span class="line">//利用-t来识别新镜像属于ouruser，v2是TAG</span><br></pre></td></tr></table></figure>
<ul>
<li>给ouruser/sinatra镜像设置TAG</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker tag 5db5f8471261 ouruser/sinatra:devel</span><br></pre></td></tr></table></figure>
<ul>
<li>查看ouruser/sinatra的TAG</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ docker images ouruser/sinatra</span><br><span class="line">REPOSITORY          TAG     IMAGE ID      CREATED        VIRTUAL SIZE</span><br><span class="line">ouruser/sinatra     latest  5db5f847126111 hours ago   446.7 MB</span><br><span class="line">ouruser/sinatra     devel   5db5f847126111 hours ago   446.7 MB</span><br><span class="line">ouruser/sinatra     v2      5db5f847126111 hours ago   446.7 MB</span><br></pre></td></tr></table></figure>
<ul>
<li>将镜像PUSH到Docker Hub</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ docker push ouruser/sinatra</span><br><span class="line">The push refers to a repository [ouruser/sinatra](len:1)Sending image list</span><br><span class="line">Pushing repository ouruser/sinatra (3 tags)...</span><br></pre></td></tr></table></figure>
<ul>
<li>从本地删除镜像</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ docker rmi training/sinatra</span><br><span class="line">Untagged: training/sinatra:latest</span><br><span class="line">Deleted:5bc342fa0b91cabf65246837015197eecfa24b2213ed6a51a8974ae250fedd8dDeleted: ed0fffdcdae5eb2c3a55549857a8be7fc8bc4241fb19ad714364cbfd7a56b22f</span><br><span class="line">Deleted:5c58979d73ae448df5af1d8142436d81116187a7633082650549c52c3a2418f0</span><br></pre></td></tr></table></figure>
<h1 id="Linking-Containers-Together"><a href="#Linking-Containers-Together" class="headerlink" title="Linking Containers Together"></a><strong>Linking Containers Together</strong></h1><ul>
<li>网络端口映射,-P随机映射到主机的49153～49155端口</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>将镜像的5000端口映射到主机的5000端口</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -p 5000:5000 training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>将镜像的5000端口映射到IP为127.0.0.1的网卡的5000端口</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -p 127.0.0.1:5000:5000 training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>将镜像的5000端口映射到主机的随机端口</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -p 127.0.0.1::5000 training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>绑定UDP端口</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -p 127.0.0.1:5000:5000/udp training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>查看指定容器的端口情况</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker port CONTAINERID[3~4] 5000127.0.0.1:49155</span><br></pre></td></tr></table></figure>
<ul>
<li>–name给镜像定义一个名称</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P --name web training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>查看镜像属性</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ docker ps -l</span><br><span class="line">CONTAINER ID  IMAGE                  COMMAND        CREATED       STATUS       PORTS                    NAMES</span><br><span class="line">aed84ee21bde  training/webapp:latest python app.py  12 hours ago  Up2 seconds 0.0.0.0:49154-&gt;5000/tcp  web</span><br></pre></td></tr></table></figure>
<ul>
<li>用inspect查看镜像名称</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ docker inspect -f &quot;&#123;&#123; .Name &#125;&#125;&quot; aed84ee21bde</span><br><span class="line">/web</span><br></pre></td></tr></table></figure>
<ul>
<li>Docker容器连接,根据training/postgre创建一个名字为db的容器，使用–name为容器定义名称</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d --name db training/postgres</span><br></pre></td></tr></table></figure>
<ul>
<li>删除已经创建过的web容器</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker rm -f web</span><br></pre></td></tr></table></figure>
<ul>
<li>创建一个新的web容器并与db容器连接，–link的使用方法–link <name or id>:alias</name></li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P --name web --link db:db training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>使用inspect查看web容器的连接情况</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">$ docker inspect -f &quot;&#123;&#123; .HostConfig.Links &#125;&#125;&quot; web</span><br><span class="line">[/db:/web/db]</span><br><span class="line"></span><br><span class="line">//You can see that the web container is now linked to the db container web/db.</span><br><span class="line"></span><br><span class="line">So what does linking the containers actually do? You&apos;ve learned that a link allows a source container to provide information about itself to a recipient container. In our example, the recipient, web, can access information about the source db. To do this, Docker creates a secure tunnel between the containers that doesn&apos;t need to expose any ports externally on the container; you&apos;ll note when we started the db container we did not use either the -P or -p flags. That&apos;s a big benefit of linking: we don&apos;t need to expose the source container, here the PostgreSQL database, to the network.</span><br><span class="line">Docker exposes connectivity information for the source container to the recipient container in two ways:</span><br><span class="line">Environment variables,</span><br><span class="line">Updating the /etc/hosts file.</span><br><span class="line"></span><br><span class="line">Environment Variables</span><br><span class="line"></span><br><span class="line">When two containers are linked, Docker will set some environment variables in the target container to enable programmatic discovery of information related to the source container.</span><br><span class="line">First, Docker will set an &lt;alias&gt;_NAME environment variable specifying the alias of each target container that was given in a --link parameter. So, for example, if a new container called web is being linked to a database container called db via --link db:webdb then in the web container would be WEBDB_NAME=/web/webdb.</span><br><span class="line">Docker will then also define a set of environment variables for each port that is exposed by the source container. The pattern followed is:</span><br><span class="line">&lt;name&gt;_PORT_&lt;port&gt;_&lt;protocol&gt; will contain a URL reference to the port. Where &lt;name&gt; is the alias name specified in the --link parameter (e.g. webdb), &lt;port&gt; is the port number being exposed, and &lt;protocol&gt; is either TCP or UDP. The format of the URL will be: &lt;protocol&gt;://&lt;container_ip_address&gt;:&lt;port&gt; (e.g. tcp://172.17.0.82:8080). This URL will then be split into the following 3 environment variables for convenience:</span><br><span class="line">&lt;name&gt;_PORT_&lt;port&gt;_&lt;protocol&gt;_ADDR will contain just the IP address from the URL (e.g. WEBDB_PORT_8080_TCP_ADDR=172.17.0.82).</span><br><span class="line">&lt;name&gt;_PORT_&lt;port&gt;_&lt;protocol&gt;_PORT will contain just the port number from the URL (e.g. WEBDB_PORT_8080_TCP_PORT=8080).</span><br><span class="line">&lt;name&gt;_PORT_&lt;port&gt;_&lt;protocol&gt;_PROTO will contain just the protocol from the URL (e.g. WEBDB_PORT_8080_TCP_PROTO=tcp).</span><br><span class="line">If there are multiple ports exposed then the above set of environment variables will be defined for each one.</span><br><span class="line">Finally, there will be an environment variable called &lt;alias&gt;_PORT that will contain the URL of the first exposed port of the source container. For example, WEBDB_PORT=tcp://172.17.0.82:8080. In this case, &apos;first&apos; is defined as the lowest numbered port that is exposed. If that port is used for both tcp and udp, then the tcp one will be specified.</span><br><span class="line">Returning back to our database example, you can run the env command to list the specified container&apos;s environment variables.</span><br><span class="line">    $ sudo docker run --rm --name web2 --link db:db training/webapp env</span><br><span class="line">    ...</span><br><span class="line">    DB_NAME=/web2/db</span><br><span class="line">    DB_PORT=tcp://172.17.0.5:5432</span><br><span class="line">    DB_PORT_5432_TCP=tcp://172.17.0.5:5432</span><br><span class="line">    DB_PORT_5432_TCP_PROTO=tcp</span><br><span class="line">    DB_PORT_5432_TCP_PORT=5432</span><br><span class="line">    DB_PORT_5432_TCP_ADDR=172.17.0.5...</span><br><span class="line">Note: These Environment variables are only set for the first process in the container. Similarly, some daemons (such as sshd) will scrub them when spawning shells for connection.</span><br><span class="line">Note: Unlike host entries in the /etc/hosts file, IP addresses stored in the environment variables are not automatically updated if the source container is restarted. We recommend using the host entries in /etc/hosts to resolve the IP address of linked containers.</span><br><span class="line">You can see that Docker has created a series of environment variables with useful information about the source db container. Each variable is prefixed with DB_, which is populated from the alias you specified above. If the alias were db1, the variables would be prefixed with DB1_. You can use these environment variables to configure your applications to connect to the database on the db container. The connection will be secure and private; only the linked web container will be able to talk to the db container.</span><br><span class="line">Updating the /etc/hosts file</span><br><span class="line"></span><br><span class="line">In addition to the environment variables, Docker adds a host entry for the source container to the /etc/hosts file. Here&apos;s an entry for the web container:</span><br><span class="line">$ sudo docker run -t -i --rm --link db:db training/webapp /bin/bash</span><br><span class="line">root@aed84ee21bde:/opt/webapp# cat /etc/hosts172.17.0.7  aed84ee21bde</span><br><span class="line">...172.17.0.5  db</span><br><span class="line">You can see two relevant host entries. The first is an entry for the web container that uses the Container ID as a host name. The second entry uses the link alias to reference the IP address of the db container. You can ping that host now via this host name.</span><br><span class="line">root@aed84ee21bde:/opt/webapp# apt-get install -yqq inetutils-ping</span><br><span class="line">root@aed84ee21bde:/opt/webapp# ping db</span><br><span class="line">PING db (172.17.0.5):48 data bytes</span><br><span class="line">56 bytes from172.17.0.5: icmp_seq=0 ttl=64 time=0.267 ms</span><br><span class="line">56 bytes from172.17.0.5: icmp_seq=1 ttl=64 time=0.250 ms</span><br><span class="line">56 bytes from172.17.0.5: icmp_seq=2 ttl=64 time=0.256 ms</span><br><span class="line">Note: In the example, you&apos;ll note you had to install ping because it was not included in the container initially.</span><br><span class="line">Here, you used the ping command to ping the db container using its host entry, which resolves to 172.17.0.5. You can use this host entry to configure an application to make use of your db container.</span><br><span class="line">Note: You can link multiple recipient containers to a single source. For example, you could have multiple (differently named) web containers attached to your db container.</span><br><span class="line">If you restart the source container, the linked containers /etc/hosts files will be automatically updated with the source container&apos;s new IP address, allowing linked communication to continue.</span><br><span class="line">$ sudo docker restart db</span><br><span class="line">db</span><br><span class="line">$ sudo docker run -t -i --rm --link db:db training/webapp /bin/bash</span><br><span class="line">root@aed84ee21bde:/opt/webapp# cat /etc/hosts172.17.0.7  aed84ee21bde</span><br><span class="line">...172.17.0.9  db</span><br></pre></td></tr></table></figure>
<h1 id="Managing-Data-in-Containers"><a href="#Managing-Data-in-Containers" class="headerlink" title="Managing Data in Containers"></a><strong>Managing Data in Containers</strong></h1><ul>
<li>添加一个数据卷</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P --name web -v /webapp training/webapp python app.py</span><br><span class="line">//在容器中创建一个新数据卷/webapp</span><br></pre></td></tr></table></figure>
<ul>
<li>挂载主机的文件夹</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P --name web -v /src/webapp:/opt/webapp training/webapp python app.py</span><br><span class="line">将主机的/src/webapp挂载到容器的/opt/webapp（存在则替换）</span><br></pre></td></tr></table></figure>
<ul>
<li>只读挂载</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d -P --name web -v /src/webapp:/opt/webapp:ro training/webapp python app.py</span><br></pre></td></tr></table></figure>
<ul>
<li>挂载主机的文件</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ docker run --rm -it -v ~/.bash_history:/.bash_history ubuntu /bin/bash</span><br></pre></td></tr></table></figure>
<ul>
<li>创建并挂载一个容器的数据卷</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">//创建一个新容器</span><br><span class="line">$ docker create -v /dbdata --name dbdata training/postgres</span><br><span class="line">//用--volumes-from标识来挂载/dbdata卷到db1容器</span><br><span class="line">$ docker run -d --volumes-from dbdata --name db1 training/postgres</span><br><span class="line">//到db2容器</span><br><span class="line">$ docker run -d --volumes-from dbdata --name db2 training/postgres</span><br><span class="line">//也可以通过挂载db1访问/dbdata</span><br><span class="line">$ docker run -d --name db3 --volumes-from db1 training/postgres</span><br></pre></td></tr></table></figure>
<ul>
<li>备份，还原和迁移数据卷</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">$ docker run --volumes-from dbdata -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata</span><br><span class="line">Here we&apos;ve launched a new container and mounted the volume from the dbdata</span><br><span class="line">container. We&apos;ve then mounted a local host directory as /backup. Finally,</span><br><span class="line">we&apos;ve passed a command that uses tar to backup the contents of the dbdata</span><br><span class="line">volume to a backup.tar file inside our /backup directory. When the command</span><br><span class="line">completes and the container stops we&apos;ll be left with a backup of our dbdata</span><br><span class="line">volume.</span><br><span class="line">//还原</span><br><span class="line">$ docker run -v /dbdata --name dbdata2 ubuntu /bin/bash</span><br><span class="line">//解包</span><br><span class="line">$ docker run --volumes-from dbdata2 -v $(pwd):/backup busybox tar xvf /backup/backup.tar</span><br></pre></td></tr></table></figure>

      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Container/" rel="tag"># Container</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/10/09/tech/引用类型详解/" rel="next" title="引用类型详解">
                <i class="fa fa-chevron-left"></i> 引用类型详解
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/23/travel/恩施大峡谷/" rel="prev" title="恩施大峡谷">
                恩施大峡谷 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  
    <div class="comments" id="comments">
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/logo1.jpg" alt="方林">
            
              <p class="site-author-name" itemprop="name">方林</p>
              <div class="site-description motion-element" itemprop="description">愿你出走半生，归来仍是少年</div>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">27</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  
                    
                      <a href="/categories/">
                    
                  
                    
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">3</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  
                    
                      <a href="/tags/">
                    
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">17</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  
                  
                    
                  
                  
                    
                  
                  <a href="https://github.com/yourname" title="GitHub &rarr; https://github.com/yourname" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  
                  
                    
                  
                  
                    
                  
                  <a href="mailto:sean_ps@163.com" title="E-Mail &rarr; mailto:sean_ps@163.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                </span>
              
            </div>
          

          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.luoo.net" title="http://www.luoo.net" rel="noopener" target="_blank">落网</a>
                  </li>
                
              </ul>
            </div>
          

          
            
          
          

        </div>
      </div>

      
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#First-Docker-Application"><span class="nav-number">1.</span> <span class="nav-text">First Docker Application</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Woking-with-Containers"><span class="nav-number">2.</span> <span class="nav-text">Woking with Containers</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Working-with-Docker-Images"><span class="nav-number">3.</span> <span class="nav-text">Working with Docker Images</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Linking-Containers-Together"><span class="nav-number">4.</span> <span class="nav-text">Linking Containers Together</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Managing-Data-in-Containers"><span class="nav-number">5.</span> <span class="nav-text">Managing Data in Containers</span></a></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

      

    </div>
  </aside>
  


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">fanglin</span>

  

  
</div>









        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

    

    
  </div>

  

<script>
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  <script src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>


  


  <script src="/js/utils.js?v=7.1.0"></script>

  <script src="/js/motion.js?v=7.1.0"></script>



  
  


  <script src="/js/affix.js?v=7.1.0"></script>

  <script src="/js/schemes/pisces.js?v=7.1.0"></script>



  
  <script src="/js/scrollspy.js?v=7.1.0"></script>
<script src="/js/post-details.js?v=7.1.0"></script>



  


  <script src="/js/next-boot.js?v=7.1.0"></script>


  

  

  

  
  

<script src="//cdn1.lncld.net/static/js/3.11.1/av-min.js"></script>



<script src="//unpkg.com/valine/dist/Valine.min.js"></script>

<script>
  var GUEST = ['nick', 'mail', 'link'];
  var guest = 'nick,mail,link';
  guest = guest.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#comments',
    verify: true,
    notify: false,
    appId: 'jjdDCzDO6jlN5yOgAbnVwdJ3-gzGzoHsz',
    appKey: 'jnjP7aorboCG7pJV6HvdMP15',
    placeholder: 'ヾﾉ≧∀≦)o来啊，快活啊!',
    avatar: 'mm',
    meta: guest,
    pageSize: '10' || 10,
    visitor: false,
    lang: 'zh-cn' || 'zh-cn'
  });
</script>




  


  




  

  

  

  

  

  

  

  

  

  

  

  

  

  

</body>
</html>
